<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Personal extends MY_Controller {
	
	public function __construct()
	{
		parent::__construct();
		$this->check_authentication(1);
		$this->lang->load('candidate', $this->session->userdata['user_lang']);
		$this->lang->load('candidate/personal', $this->session->userdata['user_lang']);
		$this->load->model('Candidate_model', 'candidate');
	}
	
	public function index()
	{
		$data['main_content'] = 'candidate/personal';
        $data['userdata'] = $this->session->userdata;
        $data['candidate'] = $this->candidate->get(array('idmember' => $this->session->userdata['idmember']));
        
        $data['extrascript'] = '';
        $data['extrascript'] .= '$("#birthday").val("'.$data['candidate']->birthday.'");';
        $data['extrascript'] .= '$("#birthmonth").val("'.$data['candidate']->birthmonth.'");';
        $data['extrascript'] .= '$("#birthyear").val("'.$data['candidate']->birthyear.'");';
        $data['extrascript'] .= '$("#idgenre").val("'.$data['candidate']->idgenre.'");';
        $data['extrascript'] .= '$("#idmaritalstatus").val("'.$data['candidate']->idmaritalstatus.'");';
        $data['extrascript'] .= '$("#idcountry").val("'.$data['candidate']->idcountry.'");';
        $data['extrascript'] .= '$("#iddrivelicense").val("'.$data['candidate']->iddrivelicense.'");';
		
        if ($data['candidate']->idtravel == 'Y')
        {
			$data['extrascript'] .= '$("#idtravel").attr("checked", true);';
		}
		
		if ($data['candidate']->idflit == 'Y')
		{
			$data['extrascript'] .= '$("#idflit").attr("checked", true);';
		}
		
		if ($data['candidate']->idhomeoffice == 'Y')
		{
			$data['extrascript'] .= '$("#idhomeoffice").attr("checked", true);';
		}
		
		if ($data['candidate']->iddeficiency == 'Y')
		{
			$data['extrascript'] .= '$("#iddeficiency").attr("checked", true);';
		}
		
        $data['page_title'] = $this->lang->line('personal_title');
        $this->load->view('template-candidate', $data);
	}
}

?>